package top.infopub.mgr.sts.service.impl;

import java.util.Date;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.google.common.collect.Maps;

import top.infopub.generic.GenericDao;
import top.infopub.generic.GenericServiceImpl;
import top.infopub.mgr.sts.dao.MonthCollectDao;
import top.infopub.model.sts.MonthCollect;
import top.infopub.mgr.sts.service.MonthCollectService;

@Service
public class MonthCollectServiceImpl extends GenericServiceImpl<MonthCollect, String> implements
		MonthCollectService {

	@Autowired
	private MonthCollectDao monthCollectDao;
	
	@Override
	public GenericDao<MonthCollect, String> getDao() {
		return monthCollectDao;
	}

    @Override
    public Page<MonthCollect> selectDataByWhere(Date monthDate, String type, String orgId,
                                                String proName, Page<MonthCollect> page) {
        PageHelper.startPage(page.getPageNum(), page.getPageSize());
        Map<String, Object> where = Maps.newHashMap();
        where.put("stsMonth", monthDate);
        if(type.equals("2")){//区域公司
            where.put("hrOrgAreaId", orgId);
        }else if(type.equals("3")){//项目公司
            where.put("hrOrgProId", orgId);
        }
        where.put("proName", proName);
        return (Page<MonthCollect>)monthCollectDao.selectDataByWhere(where);
    }

}